package utile

import player.Player
import player.PlayerManager

//扩展String输出方法

fun String.show() = print(this)
fun String.showWithEnter() = println(this)
fun showSTATRSLINE()= println("************************")
fun showSurfaceTable(){
    showSTATRSLINE()
    "欢迎来到游戏大厅".showWithEnter()
    showSTATRSLINE()
}
fun showLoginTable(){
    showSTATRSLINE()
    "玩家请输入个人信息".showWithEnter()
}
fun SetBottom(): Int {
    showALLlist(TABLE_BOTTOM_MONEY)
    return setBottomMoney()
}
fun getDATA()= readln()
fun getGameChoose() :Int{
    var choose=0
    while(true){
        "请玩家选择游戏:".show()
         choose=readln().toInt()
        if(choose in 1..3)
        {
            break;
        }
        else{
            "输入有误".showWithEnter()
        }
    }
    return choose
}
fun setBottomMoney(): Int {
    var bottomindex= readln().toInt();
    return TABLE_BOTTOM_MONEY[bottomindex-1]
}
fun setChoice():Int{
    var personchoice= readln().toInt()
    return personchoice
}
fun showALLlist(arraylist: Array<String>)
{
    for ((index,list) in arraylist.withIndex())
    {
        "${index+1}.$list \t".show()
    }
    "".showWithEnter()
}
fun showALLlist(arraylist: Array<Int>)
{
    for ((index,list) in arraylist.withIndex())
    {
        "${index+1}.$list \t".show()
    }
    "".showWithEnter()
}
fun OnlyChoicePerson(){
    showSTATRSLINE()
    showALLlist(OnlyChoic)
    showSTATRSLINE()
}
fun nomalChoicePerson(){
    showSTATRSLINE()
    showALLlist(FULLCHOIC)
    showSTATRSLINE()
}
fun getBetMoney(player:Player,lastbet:Int):Int{
    while(true)
    {
        "请输入你想要的下注的金额:".show()
        var bet= readln().toInt()
        if(bet>player.money)
        {
            "下注金额大于自己有的钱".showWithEnter()
        }
        else if(bet<lastbet)
        {
            "下注金额小于之前玩家下注金额".showWithEnter()
        }
        else{
            player.money-=bet;
            player.lastBet = bet
            return bet
            break
        }
    }
}
fun getFOLLOW_Bet(player:Player,last:Int){
    player.money-=last
}
fun getCOMPARETORPLAYER(manager: PlayerManager,my:Int):Player{
    while(true) {
        "请选择你想要比较的人:".show()
        var index = readln().toInt()
        if (manager.Players[index].isAlive&&index!=my)
        {
            return manager.Players[index]
            break
        }
    }

}
fun showPlayerPoker(p1:Player){
    showSTATRSLINE()
    "${p1.poker.numberObj.number}".showWithEnter()
    "${p1.poker.suitObj.suit}".showWithEnter()
    showSTATRSLINE()
}
